package core;
import java.util.Scanner;
import dbms.Koordinator;
import dbms.RessourcenManager;

public class Main {

	public static final int NUM_RMS = 2;
	
	private static final RessourcenManager[] _rms = new RessourcenManager[NUM_RMS]; 
	
	public Main() {}
	
	/**
	 * Hauptprogramm
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		
		for (int i = 0; i < NUM_RMS; i++) {
			_rms[i] = new RessourcenManager(i);
		}
		
		System.out.println("starte Recovery...");
		
		for (int i = 0; i < NUM_RMS; i++) {
			_rms[i].recover();
		}
		
		
		System.out.println("Recovery beendet.");
		
		System.out.println("Zum Clients starten Enter drücken");
		
		Scanner in = new Scanner(System.in);
		in.nextLine();
		in.close();  
		
		
		
		int taid = Koordinator.getInstance().begin();
		
		_rms[0].write(taid, 0, "data");
		_rms[0].write(taid, 1, "data");
		_rms[1].write(taid, 10, "data");
		_rms[1].write(taid, 11, "data");
		
		Koordinator.getInstance().commit(taid);
		
	}
}
